

#pragma  once


#if LK_DEBUGLEVEL > 1
#define DEBUG_ASSERT(x) \
    do { if (unlikely(!(x))) { panic("DEBUG ASSERT FAILED at (%s:%d): %s\n", __FILE__, __LINE__, #x); } } while (0)
#else
#define DEBUG_ASSERT(x) \
    do { } while(0)
#endif



static inline uint32_t  read_reg( uintptr_t addr )
{
   return (*((volatile uint32_t *) (addr)));
}


static inline void  write_reg( uintptr_t addr, uint32_t value )
{
  *(volatile uint32_t *)(addr) = value;
  return;
}



/**
  * This is a wrapper function for platform dependent delay 
  * Take care while passing the argument to this function 
  * @param[in] buffer pointer to be freed
  */
static inline void  plat_delay(uint32_t delay)
{
    while (delay--)
    {
        asm volatile ( "nop" );
    }

	return;
}




/* arch_intc.c */
typedef int (*irq_handler_t)( int irq, void * parg );

void  arch_irq_enable( int irq );
void  arch_irq_disable( int irq );
int  arch_irq_request( int irq, irq_handler_t handler, uint32_t flags, const char *name, void *dev );
void  arch_intc_init( void );

